#ifndef __MYARRAY_H__
#define __MYARRAY_H__

#define ElementType int
#define Free(array)  free(array);array=NULL

struct DynamicArray
{   
    ElementType *dp;
    int size;
    int len;

};
void InsertTail(struct DynamicArray *array,ElementType element);
int Initialize(struct DynamicArray *array);
void FreeArray(struct DynamicArray *array);
int ReallocArray(struct DynamicArray *array);
int InsertArray(struct DynamicArray *array,ElementType element);

void Travel(ElementType *a,int len);
void ReTravel(ElementType *a,int len);

void InsertHead(struct DynamicArray *array,ElementType element);
void InsertIndex(struct DynamicArray *array,ElementType element,int index);
void RemoveIndex(struct DynamicArray *array,int index);
void RemoveElement(struct DynamicArray *array,ElementType element);
ElementType FindByIndex(struct DynamicArray *array,int index);
int* FindByElement(struct DynamicArray*array,ElementType element);
int* FindByElement2(struct DynamicArray*array,ElementType element);
void SetValueByIndex(struct DynamicArray *array,int index,ElementType element);
void SetValueByElement(struct DynamicArray *array,ElementType old_value,ElementType new_value);
struct DynamicArray* FindIntersection(struct DynamicArray *array1,struct DynamicArray *array2);
void Deduplication(struct DynamicArray *array);
struct DynamicArray* FindUnionSet(struct DynamicArray *array1,struct DynamicArray *array2);
struct DynamicArray* MergeArray(struct DynamicArray *array1,struct DynamicArray *array2);

int IsBigger(int a,int b);
int IsSmaller(int a,int b);
void Swap(int *a,int *b);
void BubbleSort(int *a,int len,int (*Rule)(int,int));
void InsertSort(int *a,int len);
void ChooseSort(int *a,int len);
void fastSort(int *a,int start,int end);



#endif